<?php
	
	if(!class_exists('Database', false))
	{
		require_once CLASS_PATH . 'Database.class.php';
	}
	
	class Datasources
	{
		private $__dictionary__;
		private $__defined_datasources__;
	
	
		public function __construct()
		{
			global $__DATABASE_DICTIONARY__;
			$this->__dictionary__ = $__DATABASE_DICTIONARY__;
			$this->__defined_datasources__ = array();
		}
	
		final public function create()
		{

			foreach( $this->__dictionary__ as $connection_name => $connection_info )
			{			
				$this->$connection_name = new Database( $connection_info );
				$this->__defined_datasources__ []= $connection_name;
			}
			
			$default_db = DEFAULT_DATASOURCE;
			$this->default = &$this->$default_db;

		}	
		
		final public function destroy()
		{
			foreach( $this->__defined_datasources__ as $connection_name )
			{
				$this->$connection_name->disconnect();
			}
		}
		
	}
	
?>